<template>
  <div>
    <el-row :gutter="20" type="flex" class="table-top">
      <el-col :span="16">
        <el-row type="flex" class="row-bg">
          <el-col :span="6">
            <el-input v-model="input" placeholder="请输入内容"></el-input>
          </el-col>

          <el-col :span="6" :push="1">
            <el-button type="primary">搜索</el-button>
          </el-col>
        </el-row>
      </el-col>

      <el-col :span="8">
        <el-button type="primary">添加</el-button>
      </el-col>
    </el-row>
    <el-table class="table-house" :data="tableData" border style="width: 100%">
      <el-table-column fixed type="index" label="序号"> </el-table-column>
      <el-table-column prop="name" label="楼盘名称"> </el-table-column>
      <el-table-column prop="quyu" label="所属区域"> </el-table-column>
      <el-table-column prop="mianji" label="面积"> </el-table-column>
      <el-table-column prop="jiage" label="价格"> </el-table-column>
      <el-table-column prop="updated_at" label="更新时间"> </el-table-column>
      <el-table-column prop="ll" label="排序"> </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.status ? true : false"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column prop="jjr" label="经纪人"> </el-table-column>

      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >查看</el-button
          >
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="obj.pageNum"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="obj.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: () => [],
    },
    total: {
      type: Number,
      default: 0,
    },
    obj: {
      type: Object,
      default: () => {
        return {
          quyu: "",
          area: "",
          name: "",
          pageNum: 0,
          pageSize: 5,
        };
      },
    }
  },
  data() {
    return {
      input: "",
    };
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    // 切换页数
    handleCurrentChange(val) {
      this.$emit('CurrentChange', val);
    },
  },
};
</script>

<style lang="scss">
.table-top {
  padding-bottom: 20px;
}
// .table-house {
//   min-height: 500px;
// }
</style>